/**
 * @author oki
 * 
 * Grid model class to handle individual grids
 * 
 */

import java.util.ArrayList;
import java.awt.Color;
import java.awt.Point;

public class Grid {
	
	//keeps the index of the grid
	private int x;
	private int y;
	
	private Point topLeft;
	private Point bottomRight;
	
	private ArrayList<Integer> contentColors;
	private ArrayList<Integer> emptyColors;
	
	public Grid(int x, int y) {
		
		this.x = x;
		this.y = y;
		
		topLeft = new Point(0,0);
		bottomRight = new Point(0,0);
	}
	
	public void setContentColors(ArrayList<Integer> colors) {
		contentColors = colors;
	}
	
	public ArrayList<Integer> getContentColors() {
		return contentColors;
	}
	
	public void setEmptyColors(ArrayList<Integer> colors) {
		emptyColors = colors;
	}
	
	public ArrayList<Integer> getEmptyColors() {
		return emptyColors;
	}
	
	//returns true if empty colors are different than content colors
	public boolean isDirty() {
		/*
		if (!checked) {
			if (contentColors != null && emptyColors != null) {
				for (int i=0; i<contentColors.size(); i++) {
					if (contentColors.get(i) != emptyColors.get(i)) {
						dirty = true;
						break;
					}
				}
			}
		
			checked = true;
			dirty = false;
		}
		
		return dirty;
		*/
		
		if (contentColors != null && emptyColors != null) {
			for (int i=0; i<contentColors.size(); i++) {
				if (!contentColors.get(i).equals(emptyColors.get(i)) ) {
					return true;
				}
			}
		}
		
		return false;
	}
	
	public Point getGridIndex() {
		return new Point(this.x, this.y);
	}
	
	//returns the x index of the method
	public int getX() {
		return x;
	}
	
	//returns the y index of the method
	public int getY() {
		return y;
	}
	
	
	public void setTopLeft(Point point) {
		topLeft = point;
	}
	
	public void setBottomRight(Point point) {
		bottomRight = point;
	}
	
	public Point getTopLeft() {
		return topLeft;
	}
	
	public Point getBottomRight() {
		return bottomRight;
	}
	

}
